﻿@model Data.DBModels.Category
@using Utilities;
@using WebIndex1.Extensions;

@if (Model != null)
{


    <div class="h4">@Model.Name</div>
    if (Helper.GetCookie("mode") == "edit" && Request.IsAuthenticated)
    {
        @Ajax.RawActionLink("<span class = \"glyphicon glyphicon-pencil\"></span>", "EditPopUp", "Category",
        new { id = @Model.Id },
            new AjaxOptions() { HttpMethod = "Get", InsertionMode = InsertionMode.Replace, UpdateTargetId = Model.Id.ToString("N") + "popup" }
            , null)


        @Ajax.RawActionLink("<span class = \"glyphicon glyphicon-remove\"></span>", "Delete", "Category",
        new { id = @Model.Id },
                new AjaxOptions() { HttpMethod = "Post", Confirm = "Are you sure you wish to delete this website?", InsertionMode = InsertionMode.Replace, UpdateTargetId = "displayAllCategories" }
                , null)

        <div id="@Html.Raw(Model.Id.ToString("N")+"popup")" class="editBox"></div>


        @*create a new website under the category*@

        @Ajax.ActionLink("Create New Website", "EditPopUp", "Website",
        new { id = Guid.Empty, categoryId = Model.Id },
        new AjaxOptions() { HttpMethod = "Get", InsertionMode = InsertionMode.Replace, UpdateTargetId = @Model.Id.ToString("N") })

        <div id="@Model.Id.ToString("N")" class="editBox"></div>
    }
    <ul class="noListStyle">
        @if (Model.Websites.me_IsValid())
        {
            foreach (var website in Model.Websites)
            {
                <li class="websiteItem" id="@website.Id.ToString()">
                    @Html.Partial("_Website", website)
                </li>
            }
        }

    </ul>

}
